import argparse
import pandas as pd
from matplotlib import pyplot as plt


def parse_args():
    parser = argparse.ArgumentParser()

    parser.add_argument("excel_file")

    return parser.parse_args()


def main():
    args = parse_args()

    data_frame = pd.read_excel(args.excel_file)
    items = data_frame['item']
    counts = items.value_counts()

    counts.to_csv('counts.csv')
    counts = counts[counts > 20]
    print(counts)
    
    plt.figure()
    counts.plot.bar()
    plt.savefig('vis.png', bbox_inches='tight')


if __name__ == "__main__":
    main()
